//index.js
//获取应用实例
const messageService = require('../../services/messageService');
const WxParse = require('../../wxParse/wxParse.js');
var app = getApp()
Page({
  data: {
    msginfo:{},
    code : ''
  },

  bindScanCode: function() {
    app.bindScanCode();
  },
  onLoad: function (options) {
    console.log(options);
    
    var that = this;
    var user = wx.getStorageSync('user');
    if(user) {
      messageService.getMsgDetail(user.openid,options.msg_id,options.status).then((data) => {
        that.setData({
          code: data.code
        });
        if(data.code == 1) {
          var data = data.data;
          WxParse.wxParse('msgcontent','html', data.content, that,20);
          that.setData({
            msginfo: data
          });
          var pages = getCurrentPages();
          var messageListPage = pages[0];
          messageListPage.updateMsgState(options.msg_id);
        } else {
          wx.showToast({
            title: data.msg
          });
        }
        
      }, (error) => {
      });
    }
  }
})
